<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>git+hexo命令 | DIBA HOME</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="hexo常用命令1234567hexo new&amp;quot;postName&amp;quot; #新建文章hexo new page&amp;quot;pageName&amp;quot; #新建页面hexo generate #生成静态页面至public目录hexo server #开启预览访问端口（默认端口4000，&amp;apos;ctrl + c&amp;apos;关闭server）hexo deploy #将.deploy目">
<meta property="og:type" content="article">
<meta property="og:title" content="git+hexo命令">
<meta property="og:url" content="http://yoursite.com/2017/08/18/git-hexo-command/index.html">
<meta property="og:site_name" content="DIBA HOME">
<meta property="og:description" content="hexo常用命令1234567hexo new&amp;quot;postName&amp;quot; #新建文章hexo new page&amp;quot;pageName&amp;quot; #新建页面hexo generate #生成静态页面至public目录hexo server #开启预览访问端口（默认端口4000，&amp;apos;ctrl + c&amp;apos;关闭server）hexo deploy #将.deploy目">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-05-09T06:50:45.894Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="git+hexo命令">
<meta name="twitter:description" content="hexo常用命令1234567hexo new&amp;quot;postName&amp;quot; #新建文章hexo new page&amp;quot;pageName&amp;quot; #新建页面hexo generate #生成静态页面至public目录hexo server #开启预览访问端口（默认端口4000，&amp;apos;ctrl + c&amp;apos;关闭server）hexo deploy #将.deploy目">
  
    <link rel="alternate" href="/atom.xml" title="DIBA HOME" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">DIBA HOME</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-git-hexo-command" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div class="article-meta">
    <a href="/2017/08/18/git-hexo-command/" class="article-date">
  <time datetime="2017-08-18T03:00:25.000Z" itemprop="datePublished">2017-08-18</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      git+hexo命令
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="hexo常用命令"><a href="#hexo常用命令" class="headerlink" title="hexo常用命令"></a>hexo常用命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">hexo new&quot;postName&quot; #新建文章</span><br><span class="line">hexo new page&quot;pageName&quot; #新建页面</span><br><span class="line">hexo generate #生成静态页面至public目录</span><br><span class="line">hexo server #开启预览访问端口（默认端口4000，&apos;ctrl + c&apos;关闭server）</span><br><span class="line">hexo deploy #将.deploy目录部署到GitHub</span><br><span class="line">hexo help # 查看帮助</span><br><span class="line">hexo version #查看Hexo的版本</span><br></pre></td></tr></table></figure>
<h2 id="git命令"><a href="#git命令" class="headerlink" title="git命令"></a>git命令</h2><p>在你用git之前,要先报家门,否则代码不能提交<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git config --global user.name diba</span><br><span class="line">$ git config --global user.email dba.li@163.com</span><br></pre></td></tr></table></figure></p>
<p>创建版本库<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ cd E:/</span><br><span class="line">$ mkdir test</span><br><span class="line">$ git init</span><br></pre></td></tr></table></figure></p>
<a id="more"></a>
<p>在test存放你的代码文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git add index.php 把 index.php 提交到暂存区</span><br><span class="line">git commit -m &quot;新建index.php&quot; 把 index.php 提交到版本库</span><br><span class="line">git add . 提交所有变动</span><br><span class="line">git status 查看需要提交的缓冲文件</span><br><span class="line">git commit -m</span><br></pre></td></tr></table></figure></p>
<p>用rm命令删除文件,并直接commit,提交到版本库<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">$ touch foo.php # 创建foo.php</span><br><span class="line">$ git add foo.php</span><br><span class="line">$ git commit -m &quot; 练习删除&quot;</span><br><span class="line">$ ls</span><br><span class="line">foo.php index.php</span><br><span class="line"># 开始删除</span><br><span class="line">$ git rm foo.php</span><br><span class="line">rm &apos;foo.php&apos;</span><br><span class="line">$ git commit -m &quot;删除foo.php&quot;</span><br><span class="line">[master e4dc37c] 删除foo.php</span><br><span class="line">1 file changed, 0 insertions(+), 0 deletions(-)</span><br><span class="line">delete mode 100644 foo.php</span><br><span class="line">$ ls</span><br><span class="line">index.php</span><br></pre></td></tr></table></figure></p>
<p>把代码推到远程仓库</p>
<ul>
<li><p>本地库添加远程库</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git remote add origin https://git.oschina.net/lianshou/test.git</span><br><span class="line">意思是:添加1个远程库,代号是origin,地址是 https://....test.git</span><br></pre></td></tr></table></figure>
</li>
<li><p>push 推代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git push origin master 意思是,把本地的版本(默认是master),推到代号为</span><br><span class="line">origin的远程库去. 这个过程会让你输入用户名/密码,即你注册时的账户密码.</span><br></pre></td></tr></table></figure>
</li>
<li><p>clone 复制远程库</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ cd F:/</span><br><span class="line">$ git clone https://git.oschina.net/lianshou/test.git</span><br><span class="line">$ cd test</span><br><span class="line">$ ls</span><br><span class="line">index.php</span><br></pre></td></tr></table></figure>
</li>
<li><p>pull 拉取最新代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull origin master</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>其他git命令<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">git mv config.php ./inc/config.php 移动</span><br><span class="line">git mv config.php config.inc.php 改名</span><br><span class="line">git log 查看项目的日志</span><br><span class="line">git log &lt;file&gt; 查看某文件的日志</span><br><span class="line">git log . 查看本目录的日志</span><br><span class="line">git log --pretty=oneline 让日志单行显示</span><br><span class="line">git reflog 查看版本变化</span><br><span class="line">git reset --hard HEAD^ 切换为 head 的前1版本</span><br><span class="line">git reset --hard HEAD^^ 切换为 head 的前2版本</span><br><span class="line">git reset --hard HEAD~100 切换为 head 的前100版本</span><br><span class="line">git reset --hard 6207e59 利用版本号来切换</span><br><span class="line">git reset --hard 6207 版本号不用写那么长,只要能保证不与其他版本号重复就行</span><br></pre></td></tr></table></figure></p>
<p>查看分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git branch</span><br><span class="line">* master 说明只有master分支，且处于master分支</span><br></pre></td></tr></table></figure></p>
<p>创建分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch dev</span><br></pre></td></tr></table></figure></p>
<p>切换分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git checkout dev 切换到dev分支</span><br><span class="line">git branch -b dev 创建并切换到dev分支</span><br></pre></td></tr></table></figure></p>
<p>合并分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git merge dev 在主分支下合并dev分支上的内容</span><br></pre></td></tr></table></figure></p>
<p>删除分支<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch -d dev</span><br></pre></td></tr></table></figure></p>
<p>添加远程仓库<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git remote add origin https://git.oschina.net/lianshou/test.git</span><br><span class="line">git remote rename origin online 修改远程仓库名(代称)</span><br></pre></td></tr></table></figure></p>
<p>gir</p>
<blockquote>
<p>FROM 西岭老湿(<a href="http://www.xiling.me" target="_blank" rel="noopener">http://www.xiling.me</a>)</p>
</blockquote>
<blockquote>
<p>接下来 ，推荐 <a href="http://www.yanshiba.com/" target="_blank" rel="noopener">十八哥农场</a></p>
</blockquote>
<blockquote>
<p>本章完结</p>
</blockquote>
<blockquote>
<pre><code>谢谢支持
</code></pre></blockquote>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2017/08/18/git-hexo-command/" data-id="cjppdoc1900017gadsk04h67f" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2018/04/27/mysql/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          mysql
        
      </div>
    </a>
  
  
    <a href="/2017/08/17/diba/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">HEXO FIRST DAY</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">April 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">August 2017</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2018/04/27/mysql/">mysql</a>
          </li>
        
          <li>
            <a href="/2017/08/18/git-hexo-command/">git+hexo命令</a>
          </li>
        
          <li>
            <a href="/2017/08/17/diba/">HEXO FIRST DAY</a>
          </li>
        
          <li>
            <a href="/2017/08/17/hello-world/">Hello World</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 Diba Li<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>